
var cols = [[
    {type:'checkbox'}
    ,{field:'name',  title: '角色名称',sort: true}
    ,{field:'code', title: '角色代码', sort: true}
    ,{field:'description', title: '描述'}
    ,{field:'status',  title: '状态',templet: function(d){
            return d.status==0?'禁用':'正常';
        }}
    ,{ align:'center',toolbar: '#barUtil', title:"操作"}
]]
layui.config({
    base: '/static/layui/'
}).extend({
    index: 'index'
}).use(['layer','table'], function () {
    var table = layui.table,$ = layui.$;
    initTable(table, "roleTable", "/sys/role/page", cols, true, 80);
    //监听工具条
    table.on('tool(roleTable)', function(obj){
        var data = obj.data;
       if(obj.event === 'del'){
           delLayUiTable(null, null, data.id, "/sys/role/del", data.name);
        } else if(obj.event === 'edit'){
           openWindow('700px', '450px', '编辑角色', '/sys/role/formView?id=' + data.id);
        }else if (obj.event == 'auth'){
           openWindow('700px', '450px', '资源授权:'+"["+data.name+"]", '/sys/role/resourceAuthView/' + data.id);
       }else if (obj.event == 'readUser'){
           openWindow('800px', '450px', '查看用户:'+"["+data.name+"]", '/sys/role/'+data.id+'/userView');
       }
    });
    $("#del").on('click', function () {
        delLayUiTable(table, "roleTable", null, "/sys/role/del");
    });
});
